<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>017.1.3.dom编程.html</title>
    <style>
        body {
            color: pink;
        }
        .clickdiv {
            width: 300px;
            height: 300px;
            background-color: #000;
        }

        .subdiv {
            width: 100px;
            height: 100px;
            background-color: #eee;
        }

        .fuwenben {
            border: #000 2px solid;

        }
    </style>
</head>
<body>
    <div id="mydiv" class="clickdiv">click here
        <div id="subdiv" class="subdiv"  draggable="true" >subdiv</div>
         
    </div>
    <hr><br>
    <canvas id="drawing">显示 canvas</canvas>

    <hr><br>
    <input type="image" src="graphic.gif">

    <hr><br>
    <div class="fuwenben" id="richedit" contenteditable>input value here</div>

    <hr><br>
    <template id="bar"> 
        <p>1</p> 
        <p>2</p> 
        <p>3</p> 
        </template>

        <hr><br>
        
</body>
<script>
// document.getElementById('richedit').execCommand("formatblock", false, "<h1>");
    // const fwb = document.getElementById('richedit')
    // console.dir(fwb)
    document.execCommand("formatblock", false, "<h1>");


let drawing = document.getElementById("drawing"); 
// 确保浏览器支持<canvas> 
if (drawing.getContext) { 
 let context = drawing.getContext("2d"); 
// 绘制红色矩形
context.fillStyle = "#ff0000"; 
// 在坐标点(30, 10)绘制了一个宽高为 (100,30) 的矩形
 context.fillRect(30, 10, 100, 30); 
 // 绘制半透明蓝色矩形
 context.fillStyle = "rgba(0,0,255,0.5)"; 
 context.fillRect(30, 30, 50, 50);
}



const div = document.getElementById('mydiv')
div.addEventListener('click',(e)=>{
    e.preventDefault()
    console.log( 'div -> ', e);
    console.log( e.cancelable);
})
const subdiv = document.getElementById('subdiv')
subdiv.addEventListener('click',(e )=>{
    // e.preventDefault()
    e.stopPropagation()
    console.log('subdiv ===>>> ' , e);
    console.log( e.cancelable);
    console.log(e.target );
    console.log(this );
    console.log( e.currentTarget );
    // console.log(d);
})

subdiv.addEventListener('dragstart',(e )=>{
console.log('dragstart : ' , e);
})
subdiv.addEventListener('dragsend',(e )=>{

    console.log('dragsend : ' , e);
})
subdiv.addEventListener('drag',(e )=>{

    console.log('drag : ' , e);
})

Notification.requestPermission() 
 .then((permission) => { 
 console.log('User responded to permission request:', permission); 
 });

 new Notification('Title text!');
 
 setTimeout(()=>{
    new Notification('Title text!');
 },3000)



</script>
</html>